// 先引入经过自定义全局封装的 axios
import request from '/@/utils/request';



// 会员列表
export function membershipList(params: any) {
	return request({
		url: '/admin/system/user/level/list',
		method: 'GET',
		data: params,
	});
}

// 付费会员列表
export function paymembershipList(params: any) {
	return request({
		url: '/membership/list',
		method: 'GET',
		data: params,
	});
}

// 商品类型获取
export function chainList(params: any) {
	return request({
		url: '/goodstype/getChain',
		method: 'GET',
		data: params,
	});
}

// 商品品牌获取
export function brandList(params: any) {
	const paramsQuery = Object.assign({}, params, {  
		current: params.pageNum,
		size: params.pageSize,
	});  
	delete paramsQuery.pageNum;
	delete paramsQuery.pageSize
	return request({
		url: '/product/brand/list',
		method: 'POST',
		data: paramsQuery,
	});
}

// 商品品牌新增or编辑
export function brandUpSert(params: any) {
	return request({
		url: '/product/brand/upsert',
		method: 'POST',
		data: params,
	});
}

// 商品品牌删除
export function brandDelete(id: number) {
	return request({
		url: `/product/brand/remove/${id}`,
		method: 'DELETE',
		data: {},
	});
}


/**
 * 创建商品sku列表
 * @param params 要传的查询参数值
 * @returns 返回接口数据
 */
export function createSkuList(params: any) {
	return request({
		url: '/spu/createSkuList',
		method: 'POST',
		data: params,
	});
}

// 商品新增 or 编辑
export function spuCreate(params: any) {
	return request({
		url: '/product/spu/upsert',
		method: 'POST',
		data: params,
	});
}


// 商品详情
export function spuDetail(spuId: any) {
	return request({
		url: `/product/spu/findOne/${spuId}`,
		method: 'GET',
	});
}

/**
 * 商品列表
 * @param params 要传的查询参数值
 * @returns 返回接口数据
 */
export function productList(params: any) {
	const paramsQuery = Object.assign({}, params, {  
		current: params.pageNum,
		size: params.pageSize,
	});  
	delete paramsQuery.pageNum;
	delete paramsQuery.pageSize
	return request({
		url: `/product/spu/list`,
		method: 'post',
		data:paramsQuery,
	});
}

/**
 * 商品sku列表
 * @param params 要传的查询参数值
 * @returns 返回接口数据
 */
export function productSkuList(params: any) {
	const paramsQuery = Object.assign({}, params, {  
		page: params.pageNum,
		size: params.pageSize,
	});  
	delete paramsQuery.pageNum;
	delete paramsQuery.pageSize
	return request({
		url: '/new/sku/list',
		method: 'post',
		params:paramsQuery,
		data: {},
	});
}

// /**
//  * 商品spu下sku列表
//  * @param params 要传的查询参数值
//  * @returns 返回接口数据
//  */
// export function productfindOneList(spuId: number) {
// 	return request({
// 		url: `/spu/findOne/${spuId}`,
// 		method: 'GET',
// 		// data: params,
// 	});
// }

/**
 * 商品spu删除
 * @param params 要传的查询参数值
 * @returns 返回接口数据
 */
export function spuDelete(spuId: number) {
	return request({
		url: `/product/spu/removeSpu/${spuId}`,
		method: 'DELETE',
	});
}

/**
 * 商品sku删除
 * @param params 要传的查询参数值
 * @returns 返回接口数据
 */
export function skuDelete(skuId: Number) {
	return request({
		url: `/product/spu/removeSku/${skuId}`,
		method: 'DELETE',
	});
}



/**
 * 商品规格模板列表
 * @param params 要传的查询参数值
 * @returns 返回接口数据
 *
 */
export function templateList(params: any) {
	const paramsQuery = Object.assign({}, params, {  
		current: params.pageNum,
		size: params.pageSize,
	});  
	delete paramsQuery.pageNum;
	delete paramsQuery.pageSize;
	return request({
		url: '/product/template/list',
		method: 'post',
		data: paramsQuery,
	});
}
// 

/**
 * 商品规格模板新增 or 编辑
 * @param params 要传的查询参数值
 * @returns 返回接口数据
 */
export function templateAdd(params: any) {
	return request({
		url: '/product/template/upsert',
		method: 'POST',
		data: params,
	});
}

/**
 * 商品规格模板删除
 * @param params 要传的查询参数值
 * @returns 返回接口数据
 *
 */

export function templateDelete(id: Number) {
	return request({
		url: `/product/template/remove/${id}`,
		method: 'DELETE',
	});
}

/**
 * 商品规格列表
 * @param params 要传的查询参数值
 * @returns 返回接口数据
 *
 */
export function specificationList(params: any){
	const paramsQuery = Object.assign({}, params, {  
		current: params.pageNum,
		size: params.pageSize,
	});  
	delete paramsQuery.pageNum;
	delete paramsQuery.pageSize
	return request({
		url: '/product/specification/list',
		method: 'POST',
		data: paramsQuery,
	});
}

/**
 * 商品规格新增or编辑
 * @param params 要传的查询参数值
 * @returns 返回接口数据
 *
 */

export function specificationAdd(params: any) {
	return request({
		url: '/product/specification/upsert',
		method: 'POST',
		data: params,
	});
}

/**
 * 商品规格删除
 * @param params 要传的查询参数值
 * @returns 返回接口数据
 */
export function specificationDelete(id: Number) {
	return request({
		url: `/product/specification/remove/${id}`,
		method: 'DELETE',
	});
}

/**
 * 商品分类列表
 * @param params 要传的查询参数值
 * @returns 返回接口数据
 */
export function productCategoryList(params: any) {
	return request({
		url: `/product/category/tree`,
		method: 'POST',
		data: params,
	});
}

/**
 * 商品分类修改 or 编辑
 * @param params 要传的查询参数值
 * @returns 返回接口数据
 */

export function productCategoryUpsert(params: any) {
	return request({
		url: `/product/category/upsert`,
		method: 'POST',
		data: params,
	});
}

/**
 * 商品分类删除
 * @param params 
 * @returns 
 */
export function categoryDelete(id: number) {
	return request({
		url: `/product/category/remove${id}`,
		method: 'DELETE',
	});
}


/**
 * 门店列表
 * @param params 要传的查询参数值
 * @returns 返回接口数据
 */

export function nodeList(params: any) {
	return request({
		url: '/store/node/list',
		method: 'POST',
		data: params,
	});
}


// 即素材管理
// 目录列表
export function dirList() {
	return request({
		url: '/file/admin/group',
		method: 'GET',
	});
}


// 目录新增  or编辑
export function dirAdd(params: any) {
	return request({
		url: '/file/admin/group',
		method: 'POST',
		// params:paramsQuery,
		data: params,
	});
}

// 目录下文件获取
export function fileList(params: any) {
	return request({
		url: '/file/admin/file',
		method: 'GET',
		params:params,
		// data: params,
	});
}

// 目录删除
export function dirDelete(id: any, type: number) {
	return request({
		url: `/file/admin/group/${id}`,
		method: 'DELETE',
		params: {type:type},
	});
}

// 文件上传 or 移动文件目录
export function fileUpload(params: any,group:number) {
	return request({
		url: `/file/admin/file/info/${group}`,
		method: 'POST',
		// params:paramsQuery,
		data: params,
	});
}

export function fileMove(params: any,group:any) {
	return request({
		url: `/file/admin/file/info/${group}`,
		method: 'POST',
		// params:paramsQuery,
		data: params,
	});
}

// 文件删除
export function fileDelete(id: any) {
	return request({
		url: `/file/admin/file/${id}`,
		method: 'DELETE',
		// params:paramsQuery,
		// data: params,
	});
}

// 文件批量删除
export function fileBatchDelete(params: any) {
	return request({
		url: `/file/admin/file`,
		method: 'DELETE',
		// params:paramsQuery,
		data: params,
	});
}




// /api/material/add

export function materialAdd(params: any) {
	return request({
		url: "/material/add",
		method: 'POST',
		// params:paramsQuery,
		data: params,
	});
}
  

// 服务承诺列表
export function promiseList(params: any) {
	return request({
		url: '/product/promise/list',
		method: 'POST',
		data: params,
	});
}

// 服务承诺添加
export function promiseUpsert(params: any) {
	return request({
		url: '/product/promise/upsert',
		method: 'POST',
		data: params,
	});
}

// 服务承诺删除
export function promiseRemove(id: any) {
	return request({
		url: `/product/promise/remove/${id}`,
		method: 'DELETE',
		// params:paramsQuery,
		// data: params,
	});
}
